import type { Activity, ActivityUserVo, ActivityUserVoPage, ActivityVo } from '@/types/activity'
import type { Data, PageParams, TableDataInfo } from '@/types/global'
import { http } from '@/utils/http'

/**
 * 查询活动列表
 * @param data
 * @returns
 */
export const getActivityListAPI = (data: ActivityPage) =>
  http<TableDataInfo<Activity>>({
    url: '/activity/list',
    method: 'GET',
    data,
  })

/**查询活动列表参数 */
export type ActivityPage = PageParams & Activity

/**
 * 获取活动详情
 * @param id
 * @returns
 */
export const getActivityByIdAPI = (activityId: string) =>
  http<Data<ActivityVo>>({
    url: `/activity/${activityId}`,
    method: 'GET',
  })

/**
 * 活动报名
 * @param activityId
 * @returns
 */
export const postEnrollByActivityIdAPI = (activityId: string) =>
  http<Data<Activity>>({
    url: `/activity/enroll/${activityId}`,
    method: 'POST',
  })

/**
 *
 * @param activityId 用户取消报名
 * @returns
 */
export const putCancelEnrollByActivityIdAPI = (activityId: string) =>
  http<Data<Activity>>({
    url: `/activity/cancelEnroll/${activityId}`,
    method: 'PUT',
  })

export const getUserEnrollActivityAPI = (params: ActivityUserVoPage) =>
  http<TableDataInfo<ActivityUserVo>>({
    url: `/user/activityUserVoList/${params.finish}?pageNum=${params.pageNum}&pageSize=${params.pageSize}`,
    method: 'GET',
  })
